

package com.coding4play.mqtt.common.repository;

import com.coding4play.mqtt.common.entity.session.ChannelSession;
import io.netty.channel.Channel;
import io.netty.channel.group.ChannelGroup;

/**
 * 会话存储服务接口
 */
public interface ISessionRepository {

    /**
     * 存储会话
     */
    void put(String clientId, ChannelSession channelSession, int expire);

    /**
     * 设置session失效时间
     */
    void expire(String clientId, Integer expire);

    /**
     * 获取会话
     */
    ChannelSession get(String clientId);

    /**
     * clientId的会话是否存在
     */
    Boolean hasSession(String clientId);

    /**
     * 删除会话
     */
    void delete(ChannelSession channelSession);

    ChannelGroup channelGroup();

    void channelToMemoryMap(String brokerId, Channel channel);

    Channel getChannel(ChannelSession store);

}
